package flyWeightPattern.demo;

/**
 * @author： pang-yun
 * @date： 2021-12-30 15:09
 * 功能目的 ：用于
 */

public class Client {
    public static void main(String[] args) {
        WebSiteFactory webSiteFactory = new WebSiteFactory();
        //网站为内部状态   储存在享元对象内部，不会随着环境的改变而改变
        WebSite a = webSiteFactory.getWebSiteCategory("a");
        // 而使用的人 为外部状态   随环境改变而改变  不可共享的状态
        a.use(new User("A"));
        WebSite b = webSiteFactory.getWebSiteCategory("b");
        b.use(new User("B"));
        WebSite c = webSiteFactory.getWebSiteCategory("c");
        c.use(new User("C"));
        System.out.println(webSiteFactory.size());


    }
}
